package com.lxx.converter;

import java.text.SimpleDateFormat;
import java.util.Date;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.core.convert.converter.Converter;

public class DateConverter implements Converter<String, Date>  {
	private static final Logger LOGGER = LoggerFactory.getLogger(DateConverter.class);


	@Override
	public Date convert(String arg0) {
		SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");    
		df.setLenient(true);
		try {
			return df.parse(arg0);
		} catch (Exception e) {
			LOGGER.error("date convert error! args:{}", arg0, e);
		}
		return null;
	}

}
